﻿using System;

namespace ErrorDumper {
    public static class ExceptionHandlerExtensions {

        public static string HandleExceptionSafely(this IExceptionHandler handler, ExceptionPropertyCollection properties, Exception exception) {
            if (handler == null)
                return null;
            try { return handler.HandleException(properties, exception); }
            catch { return null; }
        }

        public static string HandleExceptionSafely(this IExceptionHandler handler, ExceptionPropertyCollection properties, string content) {
            if (handler == null)
                return null;
            try { return handler.HandleException(properties, content); }
            catch { return null; }
        }

        public static string HandleExceptionSafely(this IExceptionHandler handler, Exception exception) {
            if (handler == null)
                return null;
            try { return handler.HandleException(null, exception); }
            catch { return null; }
        }

        public static string HandleExceptionSafely(this IExceptionHandler handler, ExceptionPropertyCollection properties) {
            if (handler == null)
                return null;
            try { return handler.HandleException(properties, (Exception)null); }
            catch { return null; }
        }

    }
}
